[#ftl]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>[#assign module]a/${_site_}/articles/${_channel_}[/#assign][#assign moduleName="文章"]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加新${moduleName}</title>
<script type="text/javascript" src="${base}/commonjs/jquery1.7.2/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="${base}/commonjs/jquery-forms.js"></script>
<script type="text/javascript" src="${base}/commonjs/jquery.select.js"></script>
<script type="text/javascript" src="${base}/commonjs/artDialog4/artDialog.source.js?skin=blue"></script>
<script type="text/javascript" src="${base}/commonjs/artDialog4/plugins/iframeTools.source.js"></script>
<script type="text/javascript" src="${base}/commonjs/datepicker/WdatePicker.js"></script>
    <script type="text/javascript" charset="utf-8" src="${base}/commonjs/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="${base}/commonjs/ueditor/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="${base}/commonjs/ueditor/lang/zh-cn/zh-cn.js"></script>
    

<script type="text/javascript">
$(function(){
    $("#select_image").createSelect("${base}/images/list", {}, function(row){
        return [row.id, row.cell[1]+"["+row.cell[0]+"]"];
    },  ${(item.image.id)!0});
    var content = "${(item.content)!}";
    var ueditor = UE.getEditor('editor');
    ueditor.addListener("ready", function () {
        ueditor.setContent(decodeURIComponent(content), false);
    });
  $("#btadditem").bind("click", function(){
    var content = UE.getEditor('editor').getContent();
    content = encodeURIComponent(content);
    $("#hiddenContent").val(content);
    var data = $("#additemform").formSerialize();
    $.post("${base}/${module}/${((item.id)??)?string('edit','add')}", data, function(json) {
        if(!json.success){
            art.dialog.through({
              title: "[#if (item.id)??]编辑${moduleName}信息[#else]添加新${moduleName}[/#if]失败",
              icon: "error",
              content: "[#if (item.id)??]编辑${moduleName}信息[#else]添加新${moduleName}[/#if]失败！<br>"+json.err,
              width: 250,
              height: 150,
              background: '#EEE', // 背景色
              opacity: 0.05,  // 透明度
              lock: true,
              ok: true
            });
          }else{
            try{
               art.dialog.open.origin.flexGridReload(".flexme3");
            }catch(e){
               try{
                   art.dialog.top.frames["_iframe"].window.flexGridReload(".flexme3");
               }catch(e){
                   art.dialog.top.window.flexGridReload(".flexme3");
               }
            }
            art.dialog.close();
          }    	
    });
  });
});
</script>
</head>
<body>
<h3>${((item.id)??)?string('编辑','添加新')}${moduleName}</h3>
<form id="additemform" method="POST">
<input type="hidden" name="id" value=${(item.id)!0}>
标题:<input type="text" name="name" value="${(item.name)!}"/><br>
摘要:<textarea rows="3" cols="35" name="description">${(item.description)!}</textarea><br>
<input type="hidden" id="hiddenContent" name="content" value="">
<script id="editor" type="text/plain" style="width:600px;height:200px;"></script>
来源:<input type="text" name="source" value="${(item.source)!'ccms'}"><br>
配套图片:<span id="pathSpan">${(item.image.path)!}</span>
<input type="hidden" id="inputImageId" name="image.id" value="${(item.image.id)!}">
<span><input type="file" name="file" onchange="uploadImage(this)"></span><br>

[#if item.id??]
发布时间:<input type="text" name="posttime"  value="${(item.posttime?date)!}" onfocus="WdatePicker()"/><br>
置顶标记:<input type="text" name="sticky" value="${(item.sticky)!}"><br>
状态:<input type="text" name="status" value="${(item.status)!}"><br>
[/#if]
类型选择:<input type="text" name="tag" value="${(item.tag)!0}"><br>
<input type="button" value="保存新${moduleName}" id="btadditem">
</form>

<div style="position: absolute; width: 1px; height: 1px; left: -1000px; top: -1000px">
<form id="fileupload" action="${base}/uploadfile" method="POST" enctype="multipart/form-data" target="_fui">
    <input type="hidden" name="callback" value="setArticleImage">
    <div id="filecontainer"></div>
</form>
<iframe name="_fui"></iframe>
<script type="text/javascript">
function uploadImage(file){
    var span = $(file).parent();
    $(file).appendTo($("#filecontainer"));
    span.append($('<input type="file" name="file" onchange="uploadSnaptee(this);">'));
    $("#fileupload").submit();
    $("#btadditem").attr("disabled", true);
}
function setArticleImage(json){
    $("#filecontainer").html("");
    $("#pathSpan").html(json.origin);
    $("#inputImageId").val(json.id);
    $("#btadditem").attr("disabled", false);
}
</script>
</div>
</body>
</html>